package cn.doitedu.day03

import cn.doitedu.day01.utils.SparkUtil
import cn.doitedu.day03.beans.Student
import org.apache.spark.rdd.RDD

/**
 * @Date 22.3.31
 * @Created by HANGGE
 * @Description
 */
object C03_转换算子_FlatMap {
  def main(args: Array[String]): Unit = {
    // 获取环境
    val sc = SparkUtil.getSc
    val rdd = sc.textFile("data/a.txt")
    val words = rdd.flatMap(line => line.split("\\s+"))
    // 行动算子
    words.foreach(println)


    // 加载文件
/*    val rdd1 = sc.textFile("data/students.csv")
    // 将每行数据转换成数组
    val rdd2: RDD[Array[String]] = rdd1.map(line => line.split(","))
    val rdd3: RDD[List[String]] = rdd2.map(arr => arr.toList)
    // 获取每个人的名字
    val names: RDD[String] = rdd1.map(line => line.split(",")(1))*/

  }

}
